package com.yugao.fintech.draper.quartz.support;

import com.yugao.fintech.draper.quartz.annotation.ScheduledJob;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.core.type.filter.AnnotationTypeFilter;

import java.util.Set;

public class JobClassPathScanner extends ClassPathBeanDefinitionScanner {

    public JobClassPathScanner(BeanDefinitionRegistry registry, boolean useDefaultFilters) {
        super(registry, useDefaultFilters);
    }

    /**
     * @param basePackages the packages to check for annotated classes
     * @return Set<BeanDefinitionHolder>
     */
    @Override
    protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
        addIncludeFilter(new AnnotationTypeFilter(ScheduledJob.class));
        return super.doScan(basePackages);
    }
}
